<?php
$this->breadcrumbs = array(
    'Invoice' => array('index'),
    'Manage',
);
?>
<div class="box">
    <header>
        <h5><i class="icon icon-user"></i> - Manager invoice</h5>
    </header>
    <div class="box">

	<?php
	$this->widget('bootstrap.widgets.TbGridView', array(
	    'id' => 'user-grid',
	    'dataProvider' => $model->search(),
	    'filter' => $model,
	    'columns' => array(
		array(
		    'name' => 'model',
		    'header' => 'Type Post',
		    'filter' => Invoice::getListTypeModel(),
		    'value' => function($data) {
			$listType = Invoice::getListTypeModel();
			return $listType[$data->model];
		    }
//                    'htmlOptions' => array(
//                        'width' => 50
//                    )
		),
		array(
		    'name' => 'title',
		    'header' => 'Title',
		    'type' => 'raw',
		    'value' => function($data) {

			if ($data->model == Invoice::MODEL_AD) {
			    return "<a href='" . BACKEND_SITE_URL . "adv/ad/update?id=" . $data->model_id . "'>" . @$data->ad->title . "</a>";
			} else {
			    return "<a href='" . BACKEND_SITE_URL . "event/update?id=" . $data->model_id . "'>" . @$data->event->title . "</a>";
			}
		    }
//                    'htmlOptions' => array(
//                        'width' => 50
//                    )
		),
		array(
		    'header' => 'Username',
		    'name' => 'userName',
		    'type' => 'raw',
		    'value' => function($data) {
			if ($data->model == Invoice::MODEL_AD) {
			    return "<a href='" . BACKEND_SITE_URL . "user/member/update?id=" . @$data->ad->user->user_id . "'>" . h(@$data->ad->user->username, 10) . "</a>";
			} else {
			    return "<a href='" . BACKEND_SITE_URL . "user/member/update?id=" . @$data->event->user->user_id . "'>" . h(@$data->event->user->username, 10) . "</a>";
			}
		    }
		),
		array(
		    'header' => 'Price( $ )',
		    'name' => 'total',
		    'filter' => false
		),
//		'payment_method',
		'payment_code',
		array(
		    'name' => 'created',
		    'type' => 'datetime',
		    'filter' => false
		),
//		array(
//		    'class' => 'bootstrap.widgets.TbButtonColumn',
//		),
	    ),
	));
	?>
    </div>
</div>